<template>
  <Tabs>
      <TabPane label="人员图" icon="ios-body">
        <div class="container">
          <div class="opt-area-02">
            <div class="input-frame" style="width: 100%;text-alone:left;margin-bottom:10px;font-size: 14px">
              &nbsp;&nbsp;&nbsp;&nbsp;总人数: <span>{{params.totalRecord}}</span>
            </div>
            <div class="left-con">
              <div class="input-frame" style="width: 300px">
                <Input type="text" @on-click="selectlist(1)" placeholder="请输入姓名" style="width: 300px" v-model="params.name"
                      icon="ios-search"/>
              </div>
              <div class="input-frame" style="width: 300px">
                <Input type="text" @on-click="selectlist(1)" placeholder="请输入身份证号" style="width: 300px" v-model="params.cardno"
                      icon="ios-search"/>
              </div>
              <div class="input-frame" style="width: 300px">
                <Input type="text" @on-click="selectlist(1)" placeholder="请输入联系方式" style="width: 300px" v-model="params.mobile"
                      icon="ios-search"/>
              </div>
              <Button type="info" size="small" style="margin-top: 5px;margin-right:10px;margin-left:10px" @click="focusGroupModel=true">选择人员标签</Button>
              <Button type="info" size="small" @click="selectlist(1)" style="margin-top: 5px;margin-right:10px">搜索</Button>
              </div>
            <div v-if="PickfocusGroupList.length > 0" class="left-con" style="margin-top: 5px">
                当前选择标签：<Tag v-for="(item,index) in PickfocusGroupList" :key="index">{{item.name}}</Tag>
            </div>
          </div>
          <Drawer title="选择人员标签" placement="left" :closable="false" v-model="focusGroupModel">
            <Tree ref="focusGroupTree" :data="focusGroupList" show-checkbox></Tree>
          </Drawer>
          <import-excel ref="child"></import-excel>
          <import-fr ref="fr"></import-fr>
          <import-sw ref="sw"></import-sw>
          <import-tspeople ref="tspeople"></import-tspeople>
          <import-tspeople-new ref="tspeoplenew"></import-tspeople-new>
          <Table :loading="countData.loading" border :columns="columns2" :data="DataList" size="small" ref="table">
            <template slot="doorplate_id" slot-scope="{ row }">
      <!--        <span v-if="(row.doorplate_id===undefined || row.doorplate_id==='') && (row.is_kgh==='1' || row.is_kgh === undefined || row.is_kgh === '')">未入户</span>-->
      <!--        <span v-else>已入户</span>-->
              <span>已入户</span>
            </template>
            <template slot="action" slot-scope="{ row }">
              <Row style="margin-bottom: 5px; margin-top: 2px">
                <Button class="table-action-btn" type="success" size="small" @click="fillUserInfo(row)">查看</Button>
              </Row>
            </template>
          </Table>
          <Row type="flex" justify="end" class="page_style">
            <Page :current="params.pageNo" :total="params.totalRecord" show-sizer :page-size="params.pageSize" show-elevator
                  @on-change="pageAction" @on-page-size-change="pageSizeChange"/>
          </Row>
          <person-info-modal :user-info="userInfo" :control-data="controlData" :severUserInfo="severUserInfo" ref="photo"></person-info-modal>
          <Modal v-model="controlData.show1" title="输入证件号码" width="500">
            <Row>
              <Col span="6" style="text-align: right; margin-right: 10px; margin-top: 6px;">证件号码:</Col>
              <Col span="14">
                <Input v-model="controlData.cardnoInput" placeholder=""></Input>
              </Col>
            </Row>
            <div slot="footer">
              <Button type="text" size="large" @click="controlData.show1=false">取消</Button>
              <Button type="primary" size="large" @click="withCardOK">确定</Button>
            </div>
          </Modal>
          <wl-equipment :file-path="filePath" :file-name="fileName" v-model="deviceUserInfo" @change1="change"
                        :type="device_type" :is-open="openNow" ref="wlEquipment" @img-result="imgResult"></wl-equipment>
        </div>
      </TabPane>
      <TabPane label="场所图" icon="md-map">
        <div class="container">
          <div class="opt-area-02">
            <div class="input-frame" style="width: 100%;text-alone:left;margin-bottom:10px;font-size: 14px">
              &nbsp;&nbsp;&nbsp;&nbsp;总人数: <span>{{params1.totalRecord}}</span>
            </div>
            <div class="left-con">
              <div class="input-frame" style="width: 200px">
                <Select v-model="params1.merchant_type" placeholder="商户类型" clearable style="width:200px">
                  <Option v-for="item in typelist" :value="item.id" :key="item.id">{{ item.name }}</Option>
                </Select>
              </div>
              <div class="input-frame" style="width: 200px">
                <Input type="text" @on-click="selectlist1(1)" placeholder="请输入名称" style="width: 200px" v-model="params1.name"
                      icon="ios-search"/>
              </div>
              <div class="input-frame" style="width: 200px">
                <Select v-model="params1.area_type" placeholder="商户面积筛选类型" clearable style="width:200px">
                  <Option v-for="item in areaTypeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
                </Select>
              </div>
              <div class="input-frame" style="width: 200px" v-show="params1.area_type !== '4'">
                <Input type="number" clearable placeholder="请输入商户面积" style="width: 200px" v-model="params1.place_area_one"
                      />
              </div>
              <div class="input-frame" style="width: 200px" v-show="params1.area_type === '4'">
                <Input type="number" clearable placeholder="请输入商户面积开始区间" style="width: 200px" v-model="params1.place_area_start"
                      />
              </div>
              <div class="input-frame" style="width: 200px" v-show="params1.area_type === '4'">
                <Input type="number" clearable placeholder="请输入商户面积结束区间" style="width: 200px" v-model="params1.place_area_end"
                      />
              </div>
              <Button type="info" size="small" @click="selectlist1(1)" style="margin-top: 5px;margin-right:20px">搜索</Button>
              </div>
          </div>
          <Table :loading="countData1.loading" border :columns="columns21" :data="DataList1" size="small" ref="table1">
            <!-- <template slot="action" slot-scope="{ row }">
              <Row style="margin-bottom: 5px; margin-top: 2px">
                <Button class="table-action-btn" type="success" size="small" @click="fillUserInfo(row)">查看</Button>
              </Row>
            </template> -->
          </Table>
          <Row type="flex" justify="end" class="page_style">
            <Page :current="params1.pageNo" :total="params1.totalRecord" show-sizer :page-size="params1.pageSize" show-elevator
                  @on-change="pageAction1" @on-page-size-change="pageSizeChange1"/>
          </Row>
        </div>
      </TabPane>
  </Tabs>
</template>

<script>
import { findUserList, findMerchantUpList, userinfo, findSubordinateList, getAllPeopleNum, getUserListNum } from '@/api/eventlist'
import PersonInfoModal from '@/view/xian-page/mainv3/components/personInfoModal'
import { addUser } from '@/api/grid'
import ImportExcel from '../components/import-excel'
import ImportFr from '../components/import-fr'
import ImportSw from '../components/import-sw'
import { idcard2 } from '@/api/idcard'
import {
  findGardenList,
  findGardenXJList,
  // findGridModuleList,
  getAllPeopleJuZhuTypeNum, getAllPeopleUserTypeNum, findGridZYList,
  getGridPeopleRHExcel, getJuZhuTypeNumList, getUserTypeNumList, saveUserYmReason, findResourceMapList
} from '../../../../api/eventlist'
import ImportTspeople from '../components/import-tspeople'
import ImportTspeopleNew from '../components/import-tspeople-new'
import WlEquipment from '@/components/wl-equipment/index'
import UserTypeLog from '../../mainv3/components/userTypeLog'
import { createUpLoadFiles, getSign } from '../../../../api/common'

export default {
  name: 'someuserlist',
  components: {
    UserTypeLog,
    ImportTspeopleNew,
    ImportTspeople,
    ImportSw,
    ImportFr,
    ImportExcel,
    PersonInfoModal,
    WlEquipment
  },
  data () {
    return {
      YmReasonInfo: {
        modal: false,
        info: {},
        reason: '',
        is_ydjz: false,
        jzpz: ''
      },
      usertypeNum: 0,
      juzhuNum: 0,
      focusGroupModel: false,
      PickfocusGroupList: [],
      focusGroupList: [],
      openNow: false,
      fileName: 'photo.png',
      device_type: '',
      filePath: '',
      deviceUserInfo: {},
      importModal1: false,
      importModal2: false,
      importModal3: false,
      Adisabled: false,
      Bdisabled: false,
      loadData: true,
      loading: false,
      modalStr: '',
      id: '',
      row: {},
      areaTypeList: [
        { value: '1', label: '大于' },
        { value: '2', label: '小于' },
        { value: '3', label: '等于' },
        { value: '4', label: '区间' }
      ],
      countData: { loading: false },
      countData1: { loading: false },
      params: {
        name: '',
        pageNo: 1,
        pageSize: 10,
        totalRecord: 0,
        cardno: '',
        mobile: '',
        area_id: '',
        street_id: '',
        community_id: '',
        garden_id: '',
        building_id: '',
        is_kgh: '',
        ym: '',
        ymAgeBegin: '',
        ymAgeEnd: ''
      },
      params1: {
        name: '',
        pageNo: 1,
        pageSize: 10,
        totalRecord: 0,
        area_type: '0',
        cardno: '',
        mobile: '',
        area_id: '',
        street_id: '',
        community_id: '',
        garden_id: '',
        building_id: '',
        is_kgh: '',
        ym: '',
        ymAgeBegin: '',
        ymAgeEnd: ''
      },
      columns2: [
        { title: '姓名',
          key: 'name',
          // width: 100,
          align: 'center' },
        { title: '联系方式',
          key: 'mobile',
          // width: 120,
          align: 'center' },
        { title: '身份证号',
          key: 'TMcardno',
          // width: 160,
          align: 'center' },
        { title: '性别',
          key: 'sex',
          // width: 80,
          align: 'center' },
        // { title: '具体地址', key: 'present_address', minWidth: 250, align: 'center' },
        // { title: '是否入户', slot: 'doorplate_id', width: 100, align: 'center' },
        { title: '操作', align: 'center', width: 160, slot: 'action', fixed: 'right' }
      ],
      columns21: [
        { title: '名称',
          key: 'name',
          // width: 100,
          align: 'center' },
        { title: '商户类型',
          key: 'merchant_type_name',
          // width: 120,
          align: 'center' },
        { title: '场所面积',
          key: 'place_area',
          // width: 160,
          align: 'center' },
        { title: '场所负责人',
          key: 'place_fzr',
          // width: 80,
          align: 'center' },
        { title: '场所成立时间',
          key: 'place_cl_time',
          // width: 160,
          align: 'center' },
        { title: '场所负责人电话',
          key: 'place_fzr_phone',
          // width: 160,
          align: 'center' },
        { title: '场所地址',
          key: 'place_address',
          // width: 160,
          align: 'center' },
        { title: '场所营业时间',
          key: 'place_time',
          // width: 160,
          align: 'center' }
        // { title: '具体地址', key: 'present_address', minWidth: 250, align: 'center' },
        // { title: '是否入户', slot: 'doorplate_id', width: 100, align: 'center' },
        // { title: '操作', align: 'center', width: 160, slot: 'action', fixed: 'right' }
      ],
      DataList: [],
      DataList1: [],
      userOverall: {},
      controlData: {
        show1: false,
        uploadHeader: false,
        readType: 1, // 读取当前人员信息的方式 0未读取 1输入卡号 2读身份证 3人脸对比
        cardnoInput: '',
        showDetail: false,
        photo: '',
        personTags: []
      },
      userInfo: {},
      severUserInfo: {},
      List1: [],
      List2: [],
      List3: [],
      typelist: [],
      url: '',
      GridGradenList: [],
      GridBuildingList: [],
      upPicData: {
        fileName: '疫苗凭证',
        filePath: '/grid/ym/pz'
      }
    }
  },
  methods: {
    beforeUpload (file) {
      this.upPicData.fileName = this.upPicData.fileName + '.' + file.type.substring(6)
      let that = this
      const reader = new FileReader()
      reader.readAsDataURL(file)
      reader.onload = () => {
        let index = reader.result.indexOf('base64,') + 7
        that.upPicData.file = reader.result.substring(index)
        that.upPic(that.upPicData)
      }
      return false
    },
    upPic (obj) {
      var time = new Date().getTime()
      this.timeStep = time.toString()
      let param = {
        filePath: obj.filePath,
        fileName: obj.fileName,
        timestamp: this.timeStep
      }
      getSign(param).then(res => {
        if (res.data.errcode === 0) {
          createUpLoadFiles(res.data.data.docking_url, {
            sign: res.data.data.sign,
            timestamp: this.timeStep,
            filePath: obj.filePath,
            fileName: obj.fileName,
            file: obj.file
          }).then(res => {
            if (res.data.errcode === 0) {
              console.log(this.imgType, '照片类型')
              this.YmReasonInfo.jzpz = res.data.data
            } else {
              this.$Notice.error({ title: '上传失败', desc: res.data.data.msg })
            }
          })
        } else {
          this.$Notice.error({ title: '上传失败', desc: res.data.data.msg })
        }
      })
    },
    createYmReasonModel (e) {
      this.YmReasonInfo.modal = true
      this.YmReasonInfo.info = e
      this.YmReasonInfo.reason = e.reason
      this.YmReasonInfo.jzpz = e.jzpz
      if (e.is_ydjz === '1') {
        this.YmReasonInfo.is_ydjz = true
      } else {
        this.YmReasonInfo.is_ydjz = false
      }
    },
    createYmReason () {
      let data = {
        cardno: this.YmReasonInfo.info.cardno,
        reason: this.YmReasonInfo.reason,
        is_ydjz: this.YmReasonInfo.is_ydjz === true ? 1 : 0,
        jzpz: this.YmReasonInfo.jzpz
      }
      if (data.is_ydjz === 1) {
        if (data.jzpz === '' || data.jzpz === undefined) {
          this.$Notice.error({
            title: '保存失败！',
            desc: '请上传疫苗凭证！'
          })
          return
        }
      }
      saveUserYmReason(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.$Notice.success({
            title: '保存成功！',
            desc: ret.data.errmsg
          })
          this.getList()
        } else {
          this.$Notice.error({
            title: '保存失败！',
            desc: ret.data.errmsg
          })
        }
      })
    },
    withCardOption (e) {
      console.log(e, 'bfbfbfbf')
      this.controlData.cardnoInput = ''
      let that = this
      getUserListNum({ cardno: e.idcard }).then(ret => {
        if (ret.data.errcode === 0) {
          if (ret.data.data.num > 0) {
            that.params.cardno = e.idcard
            that.getList()
          } else {
            console.log('meichadao')
            that.controlData.cardnoInput = e.idcard
            that.withCardOK()
          }
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    imgResult (idcard) {
      this.getUserInfo(idcard)
      this.faceStatus = false
    },
    change (data, base64) {
      this.imgUrl = data.base64
      this.is_photo = true
    },
    // 刷身份证办理
    withCard2 () {
      this.controlData.readType = 2
      this.controlData.uploadHeader = true
      let that = this
      if (this.severUserInfo.email === 'JieYuDevice') {
        that.readIDCard(function (idcardinfo) {
          that.controlData.photo = 'data:image/png;base64,' + idcardinfo.PhotoBmp
          that.userOverall.name = idcardinfo.Name
          that.userOverall.address = idcardinfo.Address
          that.userOverall.sex = idcardinfo.Sex
          that.userOverall.folk = idcardinfo.Nation
          that.userOverall.card_type = '1'
          that.userOverall.idcard = IDCode
          that.withCardOption(that.userOverall)
        })
      } else {
        that.device_type = 'idcard'
        console.log(that.device_type, '类型哈哈哈哈')
        // that.$refs.wlEquipment.getResult()
        setTimeout(function () {
          console.log(that.deviceUserInfo.idcard, 'that.deviceUserInfo')
          that.controlData.photo = 'data:image/png;base64,' + that.deviceUserInfo.HeadPic
          that.userOverall.name = that.deviceUserInfo.name
          that.userOverall.address = that.deviceUserInfo.address
          that.userOverall.sex = that.deviceUserInfo.sex
          that.userOverall.folk = that.deviceUserInfo.folk
          that.userOverall.idcard = that.deviceUserInfo.idcard
          that.userOverall.card_type = '1'
          that.withCardOption(that.userOverall)
        }, 3000)
        // that.device_type = ''
        setTimeout(function () {
          that.device_type = ''
        }, 3000)
      }
    },
    // 读取身份证信息
    readIDCard (callback) {
      let that = this
      idcard2().then(data => {
        let result = data.data
        if (result.code === 'SUCCESS') {
          callback(result.result)
        } else {
          that.$Message.warning(result.message)
        }
      }).catch(err => {
        that.$Message.warning('没有找到读卡设备')
        console.log(err, '错误信息')
      })
    },
    getExcel () {
      getGridPeopleRHExcel().then(ret => {
        if (ret.data.errcode === 0) {
          window.open(ret.data.data.url)
        } else {
          this.$Notice.error({
            title: '获取失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    importTsPeopleExcelNew () {
      this.$refs.tspeoplenew.init()
    },
    importTsPeopleExcel () {
      this.$refs.tspeople.init()
    },
    importExcel () {
      this.$refs.child.init()
    },
    importFr () {
      this.$refs.fr.init()
    },
    importSw () {
      this.$refs.sw.init()
    },
    pageAction (page) {
      this.params.pageNo = page
      this.getList()
    },
    pageAction1 (page) {
      this.params1.pageNo = page
      this.getList1()
    },
    selectlist () {
      this.params.pageNo = 1
      this.getList()
    },
    selectlist1 () {
      this.params1.pageNo = 1
      this.getList1()
    },
    getList () {
      this.countData.loading = true
      if (this.severUserInfo.company_grade === '2') {
        this.url = '/api/ac/grid/userRegisterService/findUserLMList'
        if ((this.params.area_id === '' || this.params.area_id === undefined) &&
          (this.params.street_id === '' || this.params.street_id === undefined) &&
          (this.params.community_id === '' || this.params.community_id === undefined)) {
          this.url = '/api/ac/grid/userRegisterService/findUserLMList'
        } else {
          this.url = '/api/as/grid/user/findUserList'
        }
      } else {
        this.url = '/api/as/grid/user/findUserList'
      }
      this.params.tagfocusGroupList = []
      this.$refs.focusGroupTree.getCheckedNodes().forEach(item => {
        this.params.tagfocusGroupList.push(item.value)
      })
      if (this.params.ymAgeBegin || this.params.ymAgeEnd) {
        var pattern = /[0-9]\d*/
        if (!pattern.test(this.params.ymAgeBegin)) {
          this.$Notice.error({
            title: '查询失败！！',
            desc: '开始年龄请输入数字！'
          })
          this.countData.loading = false
          return
        }
        if (!pattern.test(this.params.ymAgeEnd)) {
          this.$Notice.error({
            title: '查询失败！！',
            desc: '结束年龄请输入数字！'
          })
          this.countData.loading = false
          return
        }
      }
      if (this.params.ymAgeBegin) {
        if (!this.params.ymAgeEnd) {
          this.$Notice.error({
            title: '查询失败！！',
            desc: '结束年龄和开始年龄都需要选择！'
          })
          this.countData.loading = false
          return
          // /[1-9]\d*/
        }
      }
      if (this.params.ymAgeEnd) {
        if (!this.params.ymAgeBegin) {
          this.$Notice.error({
            title: '查询失败！！',
            desc: '开始年龄和结束年龄都需要选择！'
          })
          this.countData.loading = false
          return
        }
      }
      if (parseInt(this.params.ymAgeBegin) > parseInt(this.params.ymAgeEnd)) {
        this.$Notice.error({
          title: '查询失败！！',
          desc: '开始年龄需小于结束年龄！'
        })
        this.countData.loading = false
        return
      }
      console.log(this.params)
      findUserList(this.params, this.url).then(res => {
        if (res.data.errcode === 0) {
          this.DataList = res.data.data.results
          if (this.url === '/api/ac/grid/userRegisterService/findUserLMList') {
            this.getAllPeopleNum(this.params)
            // this.getAllPeopleUserTypeNum(this.params)
            // this.getAllPeopleJuZhuTypeNum(this.params)
          } else {
            this.getUserListNum(this.params)
            this.getUserTypeNumList(this.params)
            this.getJuZhuTypeNum(this.params)
            // this.params.totalRecord = res.data.data.totalRecord
          }
          if (this.params.ym === 'no') {
            // this.params.ym === '18' || this.params.ym === '1218' || this.params.ym === '12'
            if (this.columns2.findIndex(item => item.key === 'reason') === -1) {
              this.columns2.push({
                title: '疫苗未接种原因',
                key: 'reason',
                minWidth: 250,
                align: 'center'
              })
            }
          } else {
            if (this.columns2.findIndex(item => item.key === 'reason') !== -1) {
              this.columns2.splice(this.columns2.findIndex(item => item.key === 'reason'), 1)
            }
          }
        } else {
          this.$Notice.error({
            title: '查询列表信息失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    getList1 () {
      this.countData1.loading = true
      console.log(this.params1)
      if (this.params1.area_type && this.params1.area_type !== '0' && this.params1.area_type === '4') {
        if (!this.params1.place_area_start) {
          this.$Notice.error({
            title: '请输入正确面积区间1'
          })
          this.countData1.loading = false
          return
        }
        if (!this.params1.place_area_end) {
          this.$Notice.error({
            title: '请输入正确面积区间2'
          })
          this.countData1.loading = false
          return
        }
        if (this.params1.place_area_end <= this.params1.place_area_start) {
          this.$Notice.error({
            title: '请输入正确面积区间3'
          })
          this.countData1.loading = false
          return
        }
      }
      if (this.params1.area_type && this.params1.area_type !== '0' && this.params1.area_type !== '4') {
        if (!this.params1.place_area_one) {
          this.$Notice.error({
            title: '请输入正确面积'
          })
          this.countData1.loading = false
          return
        }
      }
      findMerchantUpList(this.params1).then(res => {
        if (res.data.errcode === 0) {
          this.DataList1 = res.data.data.results
          this.params1.pageNo = res.data.data.pageNo
          this.params1.totalRecord = res.data.data.totalRecord
          this.countData1.loading = false
        } else {
          this.countData1.loading = false
          this.$Notice.error({
            title: '查询列表信息失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    getTypeList () {
      findGridZYList({ type: 'p' }).then(res => {
        if (res.data.errcode === 0) {
          this.typelist = res.data.data
        } else {
          this.$Notice.error({
            title: '获取商户类型失败',
            desc: res.data.errmsg
          })
        }
      })
    },
    getAllPeopleUserTypeNum (e) {
      getAllPeopleUserTypeNum(e).then(ret => {
        if (ret.data.errcode === 0) {
          this.usertypeNum = ret.data.data.num
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getAllPeopleJuZhuTypeNum (e) {
      getAllPeopleJuZhuTypeNum(e).then(ret => {
        if (ret.data.errcode === 0) {
          this.juzhuNum = ret.data.data.num
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getUserTypeNumList (e) {
      getUserTypeNumList(e).then(ret => {
        if (ret.data.errcode === 0) {
          this.usertypeNum = ret.data.data.num
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getJuZhuTypeNum (e) {
      getJuZhuTypeNumList(e).then(ret => {
        if (ret.data.errcode === 0) {
          this.juzhuNum = ret.data.data.num
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getUserListNum (e) {
      getUserListNum(e).then(ret => {
        if (ret.data.errcode === 0) {
          this.params.totalRecord = ret.data.data.num
          this.countData.loading = false
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    getAllPeopleNum (e) {
      getAllPeopleNum(e).then(ret => {
        if (ret.data.errcode === 0) {
          this.params.totalRecord = ret.data.data.num
          this.countData.loading = false
        } else {
          this.$Notice.error({
            title: '查询列表信息数量失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    pageSizeChange (e) {
      this.params.pageSize = e
      this.selectlist(this.params.pageNo)
    },
    pageSizeChange1 (e) {
      this.params1.pageSize = e
      this.selectlist1(this.params.pageNo)
    },
    // 完善用户信息
    fillUserInfo (item) {
      this.userOverall = item
      if (!this.userOverall.id) return
      this.getUserInfo(item.cardno)
      this.controlData.showDetail = true
    },
    getUserInfo (cardno) {
      this.controlData.cardno = cardno
      this.userOverall.cardno = cardno
      userinfo(cardno).then(res => {
        if (res.data.errcode === 0) {
          this.userInfo = res.data.data
          if (this.userInfo.photo === undefined) {
            this.userInfo.photo = ''
          }
          // this.$refs.photo.photoShow(this.userInfo.photo)
          if (this.userInfo.focus_group) {
            this.controlData.personTags = this.userInfo.focus_group.split(',')
          } else {
            this.controlData.personTags = []
          }
          // 不论是否上传头像，查询个人信息时包含头像则不上传
          if (this.userInfo.photo) {
            this.controlData.photo = this.userInfo.photo
            this.controlData.uploadHeader = false
          } else {
            this.controlData.photo = this.controlData.photo || this.nophoto
          }
          if (this.controlData.readType !== 2) {
            this.userOverall.name = this.userInfo.name
            this.userOverall.address = this.userInfo.address
            this.userOverall.sex = this.userInfo.sex
            this.userOverall.folk = this.userInfo.folk
          }
          this.userOverall.readCount++
          this.userOverall.id = this.userInfo.id
          this.userOverall.userInfo = this.userInfo
        } else {
          this.$Notice.error({ title: '查询失败！', desc: res.data.errmsg })
        }
      })
    },
    addPerson () { // 添加人员
      this.controlData.show1 = true
      this.controlData.cardnoInput = ''
    },
    withCardOK () { // 调取个人信息
      this.userInfo = {}
      this.getGridUserInfo(this.controlData.cardnoInput)
      this.controlData.show1 = false
    },
    getGridUserInfo (cardno) {
      this.controlData.cardno = cardno
      this.userOverall.cardno = cardno
      addUser({ cardno: cardno }).then(res => {
        if (res.data.errcode === 0) {
          if (res.data.data === null) {
            this.userInfo = { cardno: cardno }
            this.userInfo.card_type = 1
            this.controlData.personTags = []
            this.controlData.idsArr = []
            this.controlData.showDetail = true
          } else {
            this.controlData.showDetail = true
            this.userInfo = res.data.data
            if (this.userInfo.photo === undefined) {
              this.userInfo.photo = ''
            }
            if (this.userInfo.focus_group) {
              this.controlData.personTags = this.userInfo.focus_group.split(',')
            } else {
              this.controlData.personTags = []
            }
            // 不论是否上传头像，查询个人信息时包含头像则不上传
            if (this.userInfo.photo) {
              this.controlData.photo = this.userInfo.photo
              this.controlData.uploadHeader = false
            } else {
              this.controlData.photo = this.controlData.photo || this.nophoto
            }
            if (this.controlData.readType !== 2) {
              this.userOverall.name = this.userInfo.name
              this.userOverall.address = this.userInfo.address
              this.userOverall.sex = this.userInfo.sex
              this.userOverall.folk = this.userInfo.folk
            }
            this.userOverall.readCount++
            this.userOverall.id = this.userInfo.id
            this.userOverall.userInfo = this.userInfo
          }
        } else {
          this.$Notice.error({ title: '查询失败！', desc: res.data.errmsg })
          this.controlData.showDetail = false
        }
      })
    },
    findDistrictList (e1, e2) {
      let data = {
        grade: e1,
        id: e2
      }
      findSubordinateList(data).then(ret => {
        if (ret.data.errcode === 0) {
          if (e1 === 2) {
            this.List1 = ret.data.data
          } else if (e1 === 3) {
            this.List2 = ret.data.data
          } else if (e1 === 4) {
            this.List3 = ret.data.data
          }
        } else {
          this.$Notice.error({
            title: '查询失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    clearMsg (e1) {
      if (e1 === 3) {
        this.params.area_id = ''
        this.params.street_id = ''
        this.params.community_id = ''
      } else if (e1 === 4) {
        this.params.street_id = ''
        this.params.community_id = ''
      }
    },
    clearGrid (e) {
      if (e === 6) {
        this.params.garden_id = ''
        this.params.building_id = ''
      } else if (e === 7) {
        this.params.building_id = ''
      }
    },
    findGridGradenList () {
      findGardenList().then(ret => {
        if (ret.data.errcode === 0) {
          this.GridGradenList = ret.data.data
        } else {
          this.$Notice.error({ title: '获取失败', desc: ret.data.errmsg })
        }
      })
    },
    findGridBuildingList (e) {
      let data = {
        id: e
      }
      findGardenXJList(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.GridBuildingList = ret.data.data
        } else {
          this.$Notice.error({ title: '获取失败', desc: ret.data.errmsg })
        }
      }
      )
    },
    findGridModuleList () {
      findResourceMapList().then(ret => {
        this.focusGroupList = ret.data.data
      })
    }
  },
  mounted () {
    this.severUserInfo = this.$store.state.user.severUserInfo
    this.getList()
    this.getList1()
    this.getTypeList()
    this.findGridModuleList()
  },
  watch: {
    'severUserInfo.company_grade' (val) {
      if (val === '2') {
        this.findDistrictList(2, '999999999')
      } else if (val === '3') {
        this.findDistrictList(2, '999999999')
        this.params.area_id = this.severUserInfo.company_id
        this.findDistrictList(3, this.params.area_id)
        this.Adisabled = true
      } else if (val === '4') {
        this.findDistrictList(2, '999999999')
        this.params.area_id = this.severUserInfo.parent_id
        this.findDistrictList(3, this.params.area_id)
        this.params.street_id = this.severUserInfo.company_id
        this.findDistrictList(4, this.params.street_id)
        this.Adisabled = true
        this.Bdisabled = true
      } else if (val === '5') {
        this.findGridGradenList()
      }
    },
    focusGroupModel (val) {
      if (!val) {
        this.PickfocusGroupList = []
        this.PickfocusGroupList = this.$refs.focusGroupTree.getCheckedNodes()
        console.log(this.PickfocusGroupList, '========------')
      }
    }
  }
}
</script>

<style scoped>
  .page_style {
    margin: 20px 5px;
  }

  .input-frame {
    width: 120px;
    margin-right: 10px;
    float: left;
  }

  .house-list > .group {
    background: white;
    padding: 10px;
    margin-top: 10px;
  }

  .house-list > .group > .item {
    border-bottom: 1px solid #f5f5f5;
    padding: 10px 0;
  }

  .house-list > .group > .item .top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
  }

  .house-list > .group > .item .title {
    font-size: 14px;
    color: #333333;
  }

  .house-list > .group > .item .address {
    font-size: 12px;
    color: gray;
    display: flex;
    align-items: center;
  }

  .house-list > .group > .item .detail {
    font-size: 12px;
    color: dodgerblue;
  }

  .opt-area-02 {
    display: flex;
    align-items: center;
    flex-direction: column;
    border: 1px solid #abdcff;
    background-color: #f0faff;
    padding: 8px 16px 8px 16px;
    border-radius: 4px;
    margin-bottom: 10px;
  }

  .opt-area-02 .right-con {
    width: 100%;
    margin-top: 5px;
    display: flex;
  }

  .opt-area-02 .left-con {
    font-size: 14px;
    width: 100%;
  }

  .opt-area-02 .left-con span {
    font-weight: bold;
  }

  .opt-area-02 .right-con input {
    width: 150px;
    margin-right: 10px;
  }

  .opt-area-02 .right-con .input-frame {
    width: 200px;
    margin-right: 10px;
  }

  .table-action-btn {
    margin-bottom: 3px;
  }

  .container >>> .ivu-btn-small {
    height: 24px;
    padding: 0 5px;
    font-size: 12px;
    border-radius: 3px;
  }

  .btn-action {
    margin-bottom: 10px;
  }

  .mp10 {
    margin-right: 10px;
  }
  .title-style {
    color: red;
  }
  .mb20 {
    margin-bottom: 20px;
  }
  .ivu-table-row {
    height: 57px;
  }
  .demo-spin-icon-load{
    animation: ani-demo-spin 1s linear infinite;
  }
  @keyframes ani-demo-spin {
    from { transform: rotate(0deg);}
    50%  { transform: rotate(180deg);}
    to   { transform: rotate(360deg);}
  }
  .demo-spin-col{
    height: 100px;
    position: relative;
    /*border: 1px solid #eee;*/
  }
  .container>>>.ivu-icon-ios-arrow-forward:before{
    color: black;
  }
</style>
